<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>FlyGreenwich's Aircraft</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">

function validate(){
	
	if(document.getElementById("name").value.length==0){
		alert("Please key in your name. ");
		return false;
	}else if(document.getElementById("address1").value.length==0){
		alert("Please key in your address1. ");
		return false;
	}else if(document.getElementById("address2").value.length==0){
		alert("Please key in your address2. ");
		return false;
	}else if(document.getElementById("postcode").value.length==0){
		alert("Please key in your postcode. ");
		return false;
	}else if(document.getElementById("country").value.length==0){
		alert("Please key in your country. ");
		return false;
	}else{
		return true;
	}
}

</script>
</head>
<body>

<%
Integer flight_id = (Integer)request.getAttribute("flight_id");
String depart = (String)request.getAttribute("depart");
String dest = (String)request.getAttribute("dest");
String cost = (String)request.getAttribute("cost");
List timelist = (List)request.getAttribute("time");
%>

<a name="top" id="top"></a>
<center>
	<jsp:include page="/WEB-INF/pages/menu_bar.jsp"></jsp:include>
	<jsp:include page="/WEB-INF/pages/header.jsp"></jsp:include>
	<jsp:include page="/WEB-INF/pages/content.jsp"></jsp:include>
	<jsp:include page="/WEB-INF/pages/sidebar.jsp"></jsp:include>
	<div id="mainbar">
      <h1><a name="css" id="css"></a>Available Flight</h1>
      <% if(flight_id==0){ %>
      		No available flight. Please choose again. <br><br><br>
      		
      		<a href="http://localhost:8080/FlyGreenwichAirline/">Go Back</a>
      <%}else{ %>
      <br>
      You can either book ticket through our online booking system or through phone booking system. For phone booking system, please dial 010-45565787.
      <br><br>
      <form name="flight_detail" action="selectFlightServlet" method="post">
	  <table>
	  	<tr>
	  		<td>No</td>
	  		<td>Departure</td>
	  		<td>Destination</td>
	  		<td>Price</td>
	  	</tr>
	  	<tr>
	  		<td><%=flight_id %></td>
	  		<td><%=depart %></td>
	  		<td><%=dest %></td>
	  		<td><%=cost %></td>
	  	</tr>
	  	<tr><td></td></tr><tr><td></td></tr>
	  	<tr>
	  		<td colspan="4">Please select a flight. </td>
	  	</tr>
	  	<tr>
	  		<td colspan="4"><b>Available Date: </b></td>
	  	</tr>
	  	<% for(int i=0; i<timelist.size(); i++){ %>
	  	<tr>
	  		<td><input type="radio" name="flightdateselect" value="<%=timelist.get(i) %>">
	  		<input type="hidden" name="flightidselect" value="<%=flight_id %>"></td>
	  		<td colspan="3"><%=timelist.get(i) %> Time: 09:00 AM</td>
	  	</tr>
	  	<%} %>
	  </table>
	  <br><br>
	  <table>
	  	<tr>
	  		<td colspan="2">Please fill in the customer details in order to book a flight. </td>
	  	</tr>
	  	<tr>
	  		<td>Name: </td>
	  		<td><input type="text" name="name" id="name"></td>
	  	</tr>
	  	<tr>
	  		<td>Address1: </td>
	  		<td><input type="text" name="address1" id="address1"></td>
	  	</tr>
	  	<tr>
	  		<td>Address2: </td>
	  		<td><input type="text" name="address2" id="address2"></td>
	  	</tr>
	  	<tr>
	  		<td>PostCode: </td>
	  		<td><input type="text" name="postcode" id="postcode" ></td>
	  	</tr>
	  	<tr>
	  		<td>Country: </td>
	  		<td><input type="text" name="country" id="country"></td>
	  	</tr>
	  	<tr>
	  		<td colspan="2"><input type="submit" value="send" onclick="return validate()"></td>
	  	</tr>
	  </table>
	  </form>
	  <%} %>
    </div>
    <br><br><br>
	<jsp:include page="/WEB-INF/pages/footer.jsp"></jsp:include>
</center>
</body>
</html>


